package com.nakano.common.lang;

import lombok.Data;

/**
 * Created with IntelliJ IDEA.
 *
 * @author nakano_may丶
 * @date 2023/3/3
 * @project com.nakano.common.lang
 * @Version 1.0
 * @description https://nakano_may.gitee.io/mynotes/
 */
@Data
public class Result {

    private int code;
    private String msg;
    private Object data;

    public static Result succ(Object data) {
        return Result.succ(200, "操作成功", data);
    }

    public static Result succ(int code, String msg, Object data) {
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        result.setData(data);
        return result;
    }

    public static Result fail(String msg) {
        return Result.fail(400, msg, null);
    }

    public static Result fail(int code, String msg, Object data) {
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        result.setData(data);
        return result;
    }
}
